//
//  AppMain.swift
//  CJPack
//
//  Created by 陈警卫 on 2024-11-22.
//

import Foundation

/// MARK: 业务处理
extension AppDelegate {
    
    func handleFrontCompose() {
        
        let skin = CJSkin.shared
        skin.setupSkinKeys(keys: ["any", "dark"])
        skin.colorClass = CJPColor.self
        
        window?.cj_didSkin = { [weak self] kit in
            self?.setupCJPackGV()
        }
        
        let cachesPathUrl = URL(fileURLWithPath: CJFile.cachesPath)
        kCJLog(cachesPathUrl)
    }
    
    // 进入主程序
    func showRootController() {
        window?.rootViewController?.removeFromParent()
        window?.cj_removeAllSubviews()
        window?.rootViewController = CJPRootController.rootTC()
    }
    
    func setupCJPackGV() {
        GV_CJFrame_backBarItemImage = UIImage(named: "nav_back")?.cj_imageTint(color: CJPColor.fore.color)
        
        GV_CJFrame_backColor = CJPColor.back.color
        GV_CJFrame_navBarBackColor = CJPColor.navBack.color
        GV_CJFrame_navBarTintColor = CJPColor.navTint.color

        GV_CJFrame_tabTintColor = CJPColor.tabBack.color
        GV_CJFrame_tabSelColor = CJPColor.tabSelected.color
        GV_CJFrame_tabUnSelColor = CJPColor.tabNormal.color
        
    }
    
}

/// MARK: 生命周期
extension AppDelegate {
    
    func applicationWillResignActive(_ application: UIApplication) {
        // 程序即将进入后台
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // 程序进入后台
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // 程序即将进入前台
    }
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        // 程序重新激活
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // 程序终结
    }
}
